package com.example.yunhailutong.zhongtan.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.yunhailutong.zhongtan.R;
import com.example.yunhailutong.zhongtan.entity.HomeEntity.DataBean.HomeInfoBean;

import java.util.List;

public class SecondPartListViewAdapter extends BaseAdapter {
     private LayoutInflater mInflater;
     private List<HomeInfoBean> mListViewInfoBean;

    public SecondPartListViewAdapter(Context context, List<HomeInfoBean> datas) {
        mInflater = LayoutInflater.from(context);
        mListViewInfoBean = datas;
    }

    @Override
    public int getCount() {
        return mListViewInfoBean.size();
    }

    @Override
    public Object getItem(int position) {
        return mListViewInfoBean.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
         if (convertView == null) {
             convertView = mInflater.inflate(R.layout.frament_main_second_part_list_item, null);
             viewHolder = new ViewHolder();
             viewHolder.second_part_list_item_title = (TextView) convertView.findViewById(R.id.second_part_list_title);
             viewHolder.second_part_list_item_time = (TextView) convertView.findViewById(R.id.second_part_list_time);
             convertView.setTag(viewHolder);
         } else {
             viewHolder = (ViewHolder) convertView.getTag();
         }
         //在此处对viewholder变量赋值
        viewHolder.second_part_list_item_title.setText(mListViewInfoBean.get(position).getIm_title());
        viewHolder.second_part_list_item_time.setText(mListViewInfoBean.get(position).getIm_addTime());
        return convertView;
    }

    private class ViewHolder {
         TextView second_part_list_item_title;
         TextView second_part_list_item_time;
    }
}
